using System;
using System.Data;
using Utils;
using Utils.DatabaseUtils;


namespace QLBH
{
public class tblSanPhamUI
{ 
	private int idSanPham;
	public int IdSanPham
	{
		get { return idSanPham;}
		set { idSanPham = value;}
	}

	private String tenSanPham;
	public String TenSanPham
	{
		get { return tenSanPham;}
		set { tenSanPham = value;}
	}

	private String maSanPham;
	public String MaSanPham
	{
		get { return maSanPham;}
		set { maSanPham = value;}
	}

	private String maVachNSX;
	public String MaVachNSX
	{
		get { return maVachNSX;}
		set { maVachNSX = value;}
	}

	private int idDonVi;
	public int IdDonVi
	{
		get { return idDonVi;}
		set { idDonVi = value;}
	}

	private int idKhoMacDinh;
	public int IdKhoMacDinh
	{
		get { return idKhoMacDinh;}
		set { idKhoMacDinh = value;}
	}

	private int idDanhMuc;
	public int IdDanhMuc
	{
		get { return idDanhMuc;}
		set { idDanhMuc = value;}
	}

	private String xuatXu;
	public String XuatXu
	{
		get { return xuatXu;}
		set { xuatXu = value;}
	}

	private int tonKhoToiThieu;
	public int TonKhoToiThieu
	{
		get { return tonKhoToiThieu;}
		set { tonKhoToiThieu = value;}
	}

	private String anhSanPham;
	public String AnhSanPham
	{
		get { return anhSanPham;}
		set { anhSanPham = value;}
	}

	private int idNhaCungCap;
	public int IdNhaCungCap
	{
		get { return idNhaCungCap;}
		set { idNhaCungCap = value;}
	}

	private float giaMua;
	public float GiaMua
	{
		get { return giaMua;}
		set { giaMua = value;}
	}

	private float giaBan;
	public float GiaBan
	{
		get { return giaBan;}
		set { giaBan = value;}
	}

	private int nguoiTao;
	public int NguoiTao
	{
		get { return nguoiTao;}
		set { nguoiTao = value;}
	}

	public tblSanPhamUI() {}

	public tblSanPhamUI(int idSanPham, String tenSanPham, String maSanPham, String maVachNSX, int idDonVi, int idKhoMacDinh, int idDanhMuc, String xuatXu, int tonKhoToiThieu, String anhSanPham, int idNhaCungCap, float giaMua, float giaBan, int nguoiTao)
	 {
		this.idSanPham = idSanPham;
 		this.tenSanPham = tenSanPham;
 		this.maSanPham = maSanPham;
 		this.maVachNSX = maVachNSX;
 		this.idDonVi = idDonVi;
 		this.idKhoMacDinh = idKhoMacDinh;
 		this.idDanhMuc = idDanhMuc;
 		this.xuatXu = xuatXu;
 		this.tonKhoToiThieu = tonKhoToiThieu;
 		this.anhSanPham = anhSanPham;
 		this.idNhaCungCap = idNhaCungCap;
 		this.giaMua = giaMua;
 		this.giaBan = giaBan;
 		this.nguoiTao = nguoiTao;
 	}

	public int Add(String tenSanPham, String maSanPham, String maVachNSX, int idDonVi, int idKhoMacDinh, int idDanhMuc, String xuatXu, int tonKhoToiThieu, String anhSanPham, int idNhaCungCap, float giaMua, float giaBan, int nguoiTao)
	{
		try
		{
			int result = SqlHelper.ExecuteNonQuery(Common.Conn,"tblSanPham_Add",tenSanPham,maSanPham,maVachNSX,idDonVi,idKhoMacDinh,idDanhMuc,xuatXu,tonKhoToiThieu,anhSanPham,idNhaCungCap,giaMua,giaBan,nguoiTao);
			return result;
		}
		catch(Exception e) {return -1; }
	}

	public int Update(int idSanPham, String tenSanPham, String maSanPham, String maVachNSX, int idDonVi, int idKhoMacDinh, int idDanhMuc, String xuatXu, int tonKhoToiThieu, String anhSanPham, int idNhaCungCap, float giaMua, float giaBan, int nguoiTao)
	{
		try
		{
			int result = SqlHelper.ExecuteNonQuery(Common.Conn,"tblSanPham_Update",idSanPham,tenSanPham,maSanPham,maVachNSX,idDonVi,idKhoMacDinh,idDanhMuc,xuatXu,tonKhoToiThieu,anhSanPham,idNhaCungCap,giaMua,giaBan,nguoiTao);
			return result;
		}
		catch(Exception e) {return -1; }
	}

	public int Delete(int idSanPham)
	{
		try
		{
			int result = SqlHelper.ExecuteNonQuery(Common.Conn,"tblSanPham_Delete",idSanPham);
			return result;
		}
		catch(Exception e) {return -1; }
	}

	public int DeleteAll()
	{
		try
		{
			int result = SqlHelper.ExecuteNonQuery(Common.Conn,"tblSanPham_DeleteAll");
			return result;
		}
		catch(Exception e) {return -1; }
	}

	public DataSet Get(int idSanPham)
	{
		try
		{
			DataSet result = SqlHelper.ExecuteDataset(Common.Conn,"tblSanPham_Get",idSanPham);
			return result;
		}
		catch(Exception e) {return null; }
	}

	public DataSet GetAll()
	{
		try
		{
			DataSet result = SqlHelper.ExecuteDataset(Common.Conn,"tblSanPham_GetAll");
			return result;
		}
		catch(Exception e) {return null; }
	}

	public DataSet GetByIdDonVi(int idDonVi)
	{
		try
		{
			DataSet result = SqlHelper.ExecuteDataset(Common.Conn,"tblSanPham_GetByIdDonVi",idDonVi);
			return result;
		}
		catch(Exception e) {return null; }
	}

	public DataSet GetByIdKhoMacDinh(int idKhoMacDinh)
	{
		try
		{
			DataSet result = SqlHelper.ExecuteDataset(Common.Conn,"tblSanPham_GetByIdKhoMacDinh",idKhoMacDinh);
			return result;
		}
		catch(Exception e) {return null; }
	}

	public DataSet GetByIdDanhMuc(int idDanhMuc)
	{
		try
		{
			DataSet result = SqlHelper.ExecuteDataset(Common.Conn,"tblSanPham_GetByIdDanhMuc",idDanhMuc);
			return result;
		}
		catch(Exception e) {return null; }
	}

	public DataSet GetByIdNhaCungCap(int idNhaCungCap)
	{
		try
		{
			DataSet result = SqlHelper.ExecuteDataset(Common.Conn,"tblSanPham_GetByIdNhaCungCap",idNhaCungCap);
			return result;
		}
		catch(Exception e) {return null; }
	}

	public DataSet GetByNguoiTao(int nguoiTao)
	{
		try
		{
			DataSet result = SqlHelper.ExecuteDataset(Common.Conn,"tblSanPham_GetByNguoiTao",nguoiTao);
			return result;
		}
		catch(Exception e) {return null; }
	}

} 
}
